Repository navigation
fix(streaming): keep reading after a server message that fails to parse - #303
Open
mayankbohradev wants to merge 1 commit into
Open
mayankbohradev wants to merge 1 commit into
mayankbohradev wants to merge 1 commit into
Conversation
A message the client could not read raised out of the read loop. That ended the read thread or task with no Error event, and the write side kept sending audio. Both loops now call one shared reader that skips such a message with a warning. An Error or Termination message that fails validation still ends the session.
This was referenced Nov 27, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Both streaming clients now skip a server message they cannot read, and keep reading. Before, one such message ended the read thread or task with no
Errorevent.Why
_read_message(sync) and_read_loop(async) parsed each message with no guard. A pydanticValidationError(for example onenullin aTurn), a JSON value that is not an object, or a non-UTF-8 binary frame raised out of the loop. After that:TurnorTerminationwas delivered;Errorevent fired and_stop_eventstayed unset;Bad JSON and unknown event types were already skipped with a warning. This makes the other unreadable cases behave the same way.
How
_read_eventin_base.pydecodes and parses a frame for both clients. No frame content makes it raise.ErrororTerminationmessage that fails validation is not skipped. It is rebuilt from the fields that can be read, so the session still ends andon_errorstill fires.Turn, the transcript) in the exception text, so that text is not logged.Testing
masterand pass with the change.test_a_forked_child_does_not_share_the_parents_tts_connectionsfails on macOS onmastertoo.Notes for reviewers
assemblyai.streaming.v3._baselogger, because the code moved there.Errorevent carriescode=Nonewhen the code cannot be read. A rebuiltTerminationcarriesNonefor a duration that cannot be read.